import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)
const routes = [
  // 前台展示
  {
    path: '/',
    redirect: '/index',
    // component: () => import('../views/Main'),
    component:(resolve)=>{require(['../views/Main'],resolve)},
    children: [{
        path: '/index',
        name: 'index',
        component: () => import('../views/Index/Index')
      },
      {
        path: '/shopCart',
        name: 'shopCart',
        component: () => import('../views/Shop/ShopCart')
      },
      {
        path: '/shopList',
        name: 'shopList',
        component: () => import('../views/Shop/ShopList')
      },
      {
        path: '/shopDetail/:id',
        name: 'shopDetail',
        component: () => import('../views/Shop/ShopDetail')
      },
      {
        path: '/userDetail',
        name: 'userDetail',
        component: () => import('../views/User/UserDetail')
      },
      {
        path: '/userSecure',
        name: 'userSecure',
        component: () => import('../views/User/UserSecure')
      },
      {
        path: '/userAddress',
        name: 'userAddress',
        component: () => import('../views/User/UserAddress')
      },
      {
        path: '/userOrder',
        name: 'userOrder',
        component: () => import('../views/User/UserOrder')
      },
      {
        path: '/userSay',
        name: 'userSay',
        component: () => import('../views/User/UserSay')
      },
      {
        path: '/test',
        name: 'test',
        component: () => import('../views/Shop/test')
      },
      {
        path: '/shopOrder/:id',
        name: 'shopOrder',
        component: () => import('../views/Order/Order')
      },
      {
        path: '/chat',
        name: 'chat',
        component: () => import('../views/chat/index'),
      },
    ]
  },
  // 登陆注册
  {
    path: '/login',
    component: () => import('../views/AccountManage'),
    children: [{
        path: '/login',
        name: 'login',
        component: () => import('../views/AccountManage/Login')
      },
      {
        path: '/register',
        name: 'register',
        component: () => import('../views/AccountManage/Register')
      },
      {
        path: '/retrievepwd',
        name: 'retrievepwd',
        component: () => import('../views/AccountManage/RetrievePwd')
      }
    ]
  }

]

const router = new VueRouter({
  routes
})

export default router